<?php

//UMA new
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\InputGroup;
use App\Models\InputItem;
use App\Http\Resources\InputItem as InputResource;
use App\Http\Resources\InputGroup as GroupResource;
use App\Traits\TestLog;

class InputController extends Controller
{
    use TestLog;
    /**
     * 获取查询积分需要的选项
     * オプションを取得する
     * @return json response
     */
    
    public function index(Request $request)
    {
        //一次性获取全部 input_group、input_items、input_options数据
        //一度取得 input_group、input_items、input_options データ
        $datas = InputGroup::with('items.options')->get();
        //重组数据
        //再編成データ
        $result = $datas->pluck(null, 'identifier');
        //返回json数据
        //戻る json
        $this->loginfo(["get input info success"]);
        return [
            'code' => 200,
            'msg' => 'success',
            'data' => GroupResource::collection($result)
        ];
    }
}
